{% extends "base.html" %}
{% block content %}

{% if selects|length == 0 %}
	{% include 'include/getstarted.html' %}
{% else %}
<center>
	<h3>Choose server</h3>
	<p>
		<form action="{{ action }}" method="post">
			<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
			{% include 'include/select.html' %}
			<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
		</form>
		{% if not aftersave and not open %}
		<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
			Here you can work with previous versions of {%if service == 'keepalived' %}Keepalived{%else%}HAProxy{%endif%} configs. Roll back to them, view or delete		
		</div>
		{% endif %}
	</p>
	{% if aftersave %}
		<div class="alert alert-info"><b>The following files have been deleted:</b><br /> </div>
		{% if stderr %}
			{% include 'include/errors.html' %}
		{% else %}
			<div class="alert alert-success">
			{% for f in file %}
				{{f}}
			{% endfor %}
			</div>
		{% endif %}
	{% endif %}
	{% if open %}
		<center>
			<h4>Choose old version</h4>
			<form action="{{action}}" method="post">
				<label for="select_all" id="label_select_all"><b>Select all</b></label>
				<input type="checkbox" id="select_all"><br />
				{% for file in return_files %}
					<label for="{{file}}"> {{file.split('-', maxsplit=1)[1]}} </label><input type="checkbox" value="{{file}}" name="{{file}}" id="{{file}}">
					<a href="/app/versions.py?service={{service}}&serv={{serv}}&open=open&configver={{file}}" class="ui-button ui-widget ui-corner-all" title="View and upload this version of the config" style="margin-top: -6px;">
						Upload
					</a><br />
				{% endfor %}
				<input type="hidden" value="{{serv}}" name="serv">
				<input type="hidden" value="open" name="open">
				<input type="hidden" value="del" name="del">
				<p>
					<button type="submit" value="" name="" class="btn btn-default">Delete</button>
				</p>
			</form> 
		</center>	
	{% endif %}
</center>
{% endif %}
{% endblock %}
